import Axios from "axios"


const URL="https://application.5gzglt.com/v1.0/";
const URLText = "https://test.mingchetech.com/v1.0/";
const isHttp = false;
export const ip ="application.5gzglt.com";

export const brandId=100; //100  188



export function request(config){
    const instance  = Axios.create({
        baseURL: isHttp ? URL: URLText,
        timeout: 5000
        
    })
    // 请求拦截器
    instance.interceptors.request.use( config=>{
        if(localStorage.getItem("token") !=null){
            config.headers["authToken"]=localStorage.getItem("token")
        }
        // console.log("请求成功:"+JSON.stringify(config));
        return config;
    },err =>{
        console.log("请求失败:"+err);
    });
    // 响应拦截器
    instance.interceptors.response.use(res=>{
        // console.log("响应成功:"+JSON.stringify(res.data));
        return res.data;
    },err=>{
        console.log("响应失败:"+err);
    });

    return instance(config)
}

export function ajaxRequest(config){
    const instance  = Axios.create({
        timeout: 5000,
        baseURL:"http://tcc.taobao.com/"   
    })
    return instance(config)
}
